<template>
	<view class="container">
		<!-- 这里是滚动内容 -->
		<view class="content">
			<view class="list">
				<view class="item" :style="{marginTop:i.top?i.top:'1rpx'}" v-for="i in config">
					<view class="view">{{i.title}}</view>
					<view class="text" v-if="data[i.key]">{{data[i.key]}}</view>
					<view class="text" v-if="!(data[i.key])">空</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			config: {
				type: Array,
				default: [
					{
						title: '查岗人姓名',
						key: 'userName'
					},
					{
						title: 'ip地址',
						key: 'ip'
					},
					{
						title: '开始时间',
						key: 'startTime'
					},
					{
						title: '结束时间',
						key: 'endTime'
					},
					{
						title: '查岗状态',
						key: 'state'
					},
					{
						title: '查岗结果',
						key: 'result'
					}
				]
			},
			data: {
				type: Object,
				default: {
					userName: '',
					startTime: '',
					endTime: '',
					ip: '',
					state: '',
					result: ''
				}
			}
		},
		onLoad(options) {
			this.checkStr = decodeURIComponent(options.check);
			const check = JSON.parse(this.checkStr);
			console.log(check)
			this.data.id = check.id;
			this.data.userName = check.userName;
			this.data.startTime = check.startTime;
			this.data.endTime = check.endTime;
			this.data.ip = check.ip;
			this.data.result = check.result;
			this.data.state = check.state;
			if (check.state === "0") {
				this.data.stateName = "已查岗";
			} else if (check.state === "1") {
				this.data.stateName = "未查岗";
			}
		},
		data() {
			return {
				checkStr: '',
			};
		},
		methods: {}
	}
</script>

<style lang="scss" scoped>
	.container {
		overflow: hidden;
	}

	.content {
		height: calc(100% - 50px);
		/* 假设底部吸底栏高度为50px */
		overflow-y: auto;
		/* 开启滚动 */
	}

	.list {
		display: flex;
		flex-direction: column;
		background-color: #f2f2f2;
	}

	.item {
		display: flex;
		align-items: center;
		background-color: #fff;
		justify-content: space-between;
		flex-wrap: wrap;
		padding: 0 30rpx;

		&:active {
			background-color: #f2f2f2;
		}

		.view {
			padding: 30rpx 0;
			font-size: 14px;
			flex: 1;
			color: #333333;
		}

		.text {
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 0;
			overflow: hidden;
			font-size: 14px;
			color: #999;
		}
	}
</style>
